package com.dingchw.singlemusic.model.dto;

import com.dingchw.singlemusic.define.annotation.Decrypt;
import com.dingchw.singlemusic.define.exception.DataException;
import com.dingchw.singlemusic.define.request.AbstractRequest;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

@ApiModel(value="用户信息")
@Setter
@Getter
public class UserDTO extends AbstractRequest {
    @ApiModelProperty(value="用户名")
    private String username;
    @ApiModelProperty(value="密码")
    @Decrypt
    private String userpassword;
    @ApiModelProperty(value="性别")
    private String usersex;
    @ApiModelProperty(value="登录名")
    private String loginname;

    @Override
    public void check() {
        if(isEmpty(username)){
            throw new DataException("用户名不能为空");
        }
        if(isEmpty(userpassword)){
            throw new DataException("密码不能为空");
        }
        if(isEmpty(usersex)){
            throw new DataException("性别不能为空");
        }
        if(isEmpty(loginname)){
            throw new DataException("登录名不能为空");
        }
    }
}
